package fpt.store.tab;

import java.util.ArrayList;

import fpt.store.data.StoreDetails;
import fpt.store.main.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class StoreAdapter extends BaseAdapter {
	Context context;
	ArrayList<StoreDetails> data;
	private static LayoutInflater inflater = null;

	public StoreAdapter(Context context, ArrayList<StoreDetails> data) {
		super();
		this.context = context;
		this.data = data;
		inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		return data.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = convertView;
		if (view == null) {
			view = inflater.inflate(R.layout.row_store, null);
		}
		TextView textName = (TextView) view.findViewById(R.id.tvName);
        textName.setText(data.get(position).getName());
        TextView textAddress = (TextView) view.findViewById(R.id.tvAddress);
        textAddress.setText(data.get(position).getAddress());
        TextView textPhone = (TextView) view.findViewById(R.id.tvPhone);
        textPhone.setText(data.get(position).getPhone());
        TextView textTime = (TextView) view.findViewById(R.id.tvTime);
        textTime.setText(data.get(position).getTimeActivity());
		return view;
	}

}
